<?php

namespace App\Http\Controllers;

use App\Hydrators\Hydrator;
use App\Hydrators\ManagementHydrator;
use App\Models\User;
use App\Repositories\Management\ManagementFilter;
use App\Repositories\Management\ManagementRepository;
use App\Repositories\User\UserFilter;
use App\Repositories\User\UserRepository;
use App\Transformers\ManagementTransformer;
use App\Transformers\UserTransformer;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class ManagementController extends Controller
{
    public function index(ManagementRepository $managementRepository, Request $request)
    {

        $paginator = $managementRepository->getPaginator(new ManagementFilter($request));
        return $this->response->paginator($paginator, new ManagementTransformer());
    }

    public function store()
    {
        $management = $this->hydrate(new User(), new ManagementHydrator());
        return $this->response()->created(null, $management);
    }


    public function show($id)
    {
        $name = User::find($id)->get();
        return $this->response->item($name, new ManagementTransformer());
    }


    public function update($id){
        $user = User::findOrFail($id);
        $patent = $this->hydrate($user,new ManagementHydrator());
        return $this->response()->created(null,$patent);
    }


    public function destroy($id)
    {
        User::destroy($id);
        return $this->response->noContent();

    }
}


